{extend name="layout" /}
{block name="content"}
<div class="row">
  <div class="col-xs-9" id="toolbar">
    {neq name="pid" value="0"}
    <button type="button" class="btn btn-success btn-sm" onclick="window.history.go(-1);" title="返回上一级"><i class="fa fa-backward"></i> 返回上一级</button>
    {/neq}
    <button type="button" class="btn btn-success btn-sm cocoModal" isForm url="{:url('add')}" title="新增项目" fixat="1"><i class="fa fa-plus"></i> 新增</button>
    <!-- <button type="button" class="btn btn-default btn-sm cocoAjax" confirm="确定要更新缓存吗？" ajaxUrl="{:url('data_cache',array('model'=>$model))}"><i class="fa fa-retweet"></i> 更新缓存</button> -->
    <button type="button" class="btn btn-danger btn-sm btnAction" data-type="delAll" confirm="确定要删除吗？" checkItem="1:0" ajaxUrl="{:url('data_delete',array('model'=>$model))}"><i class="fa fa-remove"></i> 批量删除</button>
  </div>
  <div class="col-xs-3"  style="text-align: right">
    <form>
    <div class="input-group input-group-sm demoTable">
        <input type="text" class="form-control input-sm" name="keywords" id="demoReload" autocomplete="off"><!-- keywords -->
        <span class="input-group-btn">
          <button class="btn btn-info btn-flat layui-btn" data-type="reload">搜  索</button>
        </span>
    </div>
    </form>
  </div>
</div>
<table class="layui-table" lay-data="{height: 'full-75', cellMinWidth: 80, page: true, id:'lists',limit:30, url:'{:url('data_show_where',['whereData'=>$whereData])}'}" lay-filter="lists">
  <thead>
    <tr class="layui-colla-content">
      <th lay-data="{type:'checkbox'}">ID</th>
      <th lay-data="{field:'id', sort: true}">ID</th>
      <th lay-data="{field:'title'}">名称</th>
      <th lay-data="{field:'pname'}">上级菜单</th>
      <th lay-data="{field:'url'}">URL</th>
      <th lay-data="{field:'sort', edit: 'text'}">排序</th>
      <th lay-data="{field:'devname'}">仅开发者可见</th>
      <th lay-data="{field:'hidename'}">隐藏</th>
      <th lay-data="{fixed: 'right', width:200, align:'center', toolbar: '#barDemo'}">操作</th>
  </thead>
</table>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-xs" lay-event="child">查看子菜单</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
{/block}
{block name="script"}
<script type="text/javascript">
  function child(data){
    location.href = APP_URL + window.location.pathname + '?pid=' + data.id
  }
</script>
<script type="text/javascript">
  layui.use('table', function(){
    var table = layui.table;
    var $ = layui.$, active = {
      reload: function(){
        var demoReload = $('#demoReload');
        //执行重载
        table.reload('lists', {
          page: {
            curr: 1 //重新从第 1 页开始
          }
          ,where: {
            key: {
              keywords: demoReload.val()
            }
          }
        });
      }
    };
    $('.demoTable .layui-btn').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
</script>
{/block}